package com.flame.workflow.ru.service;

import com.flame.workflow.ru.entity.TaskProperty;
import com.flame.workflow.ru.mapper.TaskPropertyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class TaskPropertyService {

    @Autowired
    private TaskPropertyMapper taskPropertyMapper;

    public void addTaskProperty(Long instanceId, Long taskId, Map<String, String> nodeProperties) {
        for (Map.Entry<String, String> entry : nodeProperties.entrySet()) {
            TaskProperty taskProperty = new TaskProperty();
            taskProperty.setInstanceId(instanceId);
            taskProperty.setTaskId(taskId);
            taskProperty.setPropertyKey(entry.getKey());
            taskProperty.setPropertyValue(entry.getValue());
            taskPropertyMapper.insert(taskProperty);
        }
    }
}
